<template>
  <div class="profile-container">
    <!-- 顶部个人信息横幅 -->
    <div class="profile-hero">
      <div class="hero-background"></div>
      <div class="hero-content">
        <div class="user-avatar-section">
          <div class="avatar-wrapper" @click="changeAvatar">
            <img :src="userForm.avatarUrl || '/images/avatars/default-user.png'" 
                 alt="用户头像" 
                 class="user-avatar">
            <div class="avatar-edit-overlay">
              <el-icon><Camera /></el-icon>
            </div>
          </div>
        </div>
        <div class="user-info">
          <h1 class="username">{{ userForm.username }}</h1>
          <p class="user-role">{{ getRoleText(userForm.userRole) }}</p>
          <div class="user-meta">
            <span class="meta-item">
              <el-icon><Calendar /></el-icon>
              加入 {{ getAccountDays() }} 天
            </span>
            <span class="meta-item">
              <el-icon><Clock /></el-icon>
              最后登录：{{ formatDate(userForm.lastLoginAt) || '暂无记录' }}
            </span>
          </div>
        </div>
      </div>
    </div>

    <!-- 统计卡片区域 -->
    <div class="stats-section">
      <div class="stats-grid">
        <div class="stat-card">
          <div class="stat-icon account-status">
            <el-icon><User /></el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">
              <el-tag :type="userForm.userStatus === 'active' ? 'success' : 'danger'" 
                      size="small">
                {{ getStatusText(userForm.userStatus) }}
              </el-tag>
            </div>
            <div class="stat-label">账户状态</div>
          </div>
        </div>
        
        <div class="stat-card">
          <div class="stat-icon join-date">
            <el-icon><Star /></el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ formatDate(userForm.createdAt) }}</div>
            <div class="stat-label">注册时间</div>
          </div>
        </div>
      </div>
    </div>

    <!-- 功能卡片区域 -->
    <div class="cards-section">
      <div class="cards-grid">
        <!-- 基本信息卡片 -->
        <div class="info-card">
          <div class="card-header">
            <h3>基本信息</h3>
            <el-button type="primary" text @click="openEditProfileDialog">
              <el-icon><Edit /></el-icon>
              编辑
            </el-button>
          </div>
          <div class="card-content">
            <div class="info-item">
              <div class="info-label">
                <el-icon><User /></el-icon>
                用户名
              </div>
              <div class="info-value">{{ userForm.username }}</div>
            </div>
            <div class="info-item">
              <div class="info-label">
                <el-icon><Message /></el-icon>
                邮箱
              </div>
              <div class="info-value">{{ userForm.email }}</div>
            </div>
            <div class="info-item">
              <div class="info-label">
                <el-icon><UserFilled /></el-icon>
                角色
              </div>
              <div class="info-value">{{ getRoleText(userForm.userRole) }}</div>
            </div>
          </div>
        </div>

        <!-- 安全设置卡片 -->
        <div class="info-card">
          <div class="card-header">
            <h3>安全设置</h3>
            <el-button type="primary" text @click="openChangePasswordDialog">
              <el-icon><Key /></el-icon>
              修改密码
            </el-button>
          </div>
          <div class="card-content">
            <div class="info-item">
              <div class="info-label">
                <el-icon><Lock /></el-icon>
                登录密码
              </div>
              <div class="info-value">••••••••</div>
            </div>
            <div class="info-item">
              <div class="info-label">
                <el-icon><Operation /></el-icon>
                账户安全
              </div>
              <div class="info-value">
                <el-tag type="success" size="small">安全</el-tag>
              </div>
            </div>
          </div>
        </div>

        <!-- 活动记录卡片 -->
        <div class="info-card full-width">
          <div class="card-header">
            <h3>最近活动</h3>
            <el-button type="primary" text>
              <el-icon><More /></el-icon>
              查看更多
            </el-button>
          </div>
          <div class="card-content">
            <div class="activity-list">
              <div class="activity-item">
                <div class="activity-icon">
                  <el-icon><Check /></el-icon>
                </div>
                <div class="activity-content">
                  <div class="activity-title">登录成功</div>
                  <div class="activity-time">{{ formatDate(userForm.lastLoginAt) }}</div>
                </div>
              </div>
              <div class="activity-item">
                <div class="activity-icon">
                  <el-icon><Edit /></el-icon>
                </div>
                <div class="activity-content">
                  <div class="activity-title">更新个人信息</div>
                  <div class="activity-time">{{ formatDate(userForm.createdAt) }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 编辑基本信息弹窗 -->
    <el-dialog v-model="editProfileVisible" title="编辑基本信息" width="500px" :before-close="handleCloseEditProfile">
      <el-form :model="editForm" :rules="formRules" ref="editFormRef" label-width="80px">
        <el-form-item label="邮箱" prop="email">
          <el-input v-model="editForm.email" type="email" placeholder="请输入邮箱">
            <template #prefix>
              <el-icon><Message /></el-icon>
            </template>
          </el-input>
        </el-form-item>
      </el-form>
      
      <template #footer>
        <el-button @click="editProfileVisible = false">取消</el-button>
        <el-button type="primary" @click="updateProfile" :loading="updateLoading">
          保存
        </el-button>
      </template>
    </el-dialog>

    <!-- 修改密码弹窗 -->
    <el-dialog v-model="changePasswordVisible" title="修改密码" width="500px" :before-close="handleCloseChangePassword">
      <el-form :model="passwordForm" :rules="passwordRules" ref="passwordFormRef" label-width="80px">
        <el-form-item label="当前密码" prop="currentPassword">
          <el-input v-model="passwordForm.currentPassword" type="password" show-password placeholder="请输入当前密码">
            <template #prefix>
              <el-icon><Lock /></el-icon>
            </template>
          </el-input>
        </el-form-item>

        <el-form-item label="新密码" prop="newPassword">
          <el-input v-model="passwordForm.newPassword" type="password" show-password placeholder="请输入新密码">
            <template #prefix>
              <el-icon><Key /></el-icon>
            </template>
          </el-input>
        </el-form-item>

        <el-form-item label="确认密码" prop="confirmPassword">
          <el-input v-model="passwordForm.confirmPassword" type="password" show-password placeholder="请再次输入新密码">
            <template #prefix>
              <el-icon><Key /></el-icon>
            </template>
          </el-input>
        </el-form-item>
      </el-form>
      
      <template #footer>
        <el-button @click="changePasswordVisible = false">取消</el-button>
        <el-button type="primary" @click="changePassword" :loading="passwordLoading">
          确认修改
        </el-button>
      </template>
    </el-dialog>

    <!-- 头像上传弹窗 -->
    <el-dialog v-model="avatarDialogVisible" title="更换头像" width="500px">
      <div class="avatar-upload">
        <el-upload
          class="avatar-uploader"
          action="#"
          :show-file-list="false"
          :before-upload="beforeAvatarUpload"
          :on-change="handleAvatarChange"
          :auto-upload="false"
        >
          <img v-if="previewAvatar" :src="previewAvatar" class="avatar-preview" />
          <div v-else class="avatar-uploader-placeholder">
            <el-icon class="avatar-uploader-icon"><Plus /></el-icon>
            <div class="upload-text">点击上传头像</div>
          </div>
        </el-upload>
        <div class="upload-tips">
          <p>{{ uploadConfig?.uploadTip || '支持 JPG、PNG、GIF、WEBP 格式，文件大小不超过 5MB' }}</p>
          <p>建议尺寸：200x200 像素</p>
        </div>
      </div>
      <template #footer>
        <div class="avatar-dialog-footer">
          <div class="footer-left">
<!--            <el-button -->
<!--              type="danger" -->
<!--              plain -->
<!--              @click="deleteAvatar" -->
<!--              :disabled="avatarLoading"-->
<!--              v-if="userForm.avatarUrl && !userForm.avatarUrl.includes('default-user.png')"-->
<!--            >-->
<!--              删除头像-->
<!--            </el-button>-->
          </div>
          <div class="footer-right">
<!--            <el-button @click="cancelAvatar">取消</el-button>-->
            <el-button type="primary" @click="saveAvatar" :loading="avatarLoading">保存</el-button>
          </div>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { 
  Camera, Edit, User, Message, Key, Plus, Lock, Operation, 
  Calendar, Clock, Star, 
  UserFilled, Check, More
} from '@element-plus/icons-vue'
import { auth } from '@/utils/auth'
import authApi from '@/api/auth'
import avatarApi from '@/api/avatar'

// 弹窗控制
const editProfileVisible = ref(false)
const changePasswordVisible = ref(false)
const avatarDialogVisible = ref(false)

// 用户信息表单
const userForm = reactive({
  userId: null,
  username: '',
  email: '',
  avatarUrl: '',
  userRole: '',
  userStatus: '',
  createdAt: null,
  lastLoginAt: null
})

// 编辑表单
const editForm = reactive({
  email: ''
})

// 密码修改表单
const passwordForm = reactive({
  currentPassword: '',
  newPassword: '',
  confirmPassword: ''
})

// 表单验证规则
const formRules = {
  email: [
    { required: true, message: '请输入邮箱', trigger: 'blur' },
    { type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' }
  ]
}

const passwordRules = {
  currentPassword: [
    { required: true, message: '请输入当前密码', trigger: 'blur' }
  ],
  newPassword: [
    { required: true, message: '请输入新密码', trigger: 'blur' },
    { min: 6, max: 20, message: '密码长度必须在6-20字符之间', trigger: 'blur' }
  ],
  confirmPassword: [
    { required: true, message: '请确认新密码', trigger: 'blur' },
    {
      validator: (rule, value, callback) => {
        if (value !== passwordForm.newPassword) {
          callback(new Error('两次输入的密码不一致'))
        } else {
          callback()
        }
      },
      trigger: 'blur'
    }
  ]
}

// 表单引用
const editFormRef = ref(null)
const passwordFormRef = ref(null)

// 加载状态
const updateLoading = ref(false)
const passwordLoading = ref(false)
const avatarLoading = ref(false)

// 头像相关
const previewAvatar = ref('')
const uploadConfig = ref(null)
const selectedFile = ref(null)  // 添加文件引用

// 初始化用户信息
onMounted(() => {
  loadUserInfo()
  loadUploadConfig()
})

// 加载用户信息
const loadUserInfo = async () => {
  try {
    const response = await authApi.getProfile()
    if (response.code === 200) {
      Object.assign(userForm, response.data)
      auth.setUser(response.data)
    } else {
      const user = auth.getUser()
      if (user) {
        Object.assign(userForm, user)
      }
    }
  } catch (error) {
    const user = auth.getUser()
    if (user) {
      Object.assign(userForm, user)
    }
  }
}

// 加载上传配置
const loadUploadConfig = async () => {
  try {
    const response = await avatarApi.getUploadConfig()
    if (response.code === 200) {
      uploadConfig.value = response.data
    }
  } catch (error) {
    console.warn('获取上传配置失败:', error)
  }
}

// 工具函数
const getRoleText = (role) => {
  const roleMap = {
    'admin': '管理员',
    'user': '普通用户'
  }
  return roleMap[role] || role
}

const getStatusText = (status) => {
  const statusMap = {
    'active': '正常',
    'inactive': '禁用',
    'banned': '封禁'
  }
  return statusMap[status] || status
}

const formatDate = (date) => {
  if (!date) return ''
  return new Date(date).toLocaleString('zh-CN')
}

const getAccountDays = () => {
  if (!userForm.createdAt) return 0
  const created = new Date(userForm.createdAt)
  const now = new Date()
  return Math.floor((now - created) / (1000 * 60 * 60 * 24))
}

// 弹窗操作
const openEditProfileDialog = () => {
  editForm.email = userForm.email
  editProfileVisible.value = true
}

const openChangePasswordDialog = () => {
  passwordForm.currentPassword = ''
  passwordForm.newPassword = ''
  passwordForm.confirmPassword = ''
  changePasswordVisible.value = true
}

const handleCloseEditProfile = () => {
  editFormRef.value?.resetFields()
  editProfileVisible.value = false
}

const handleCloseChangePassword = () => {
  passwordFormRef.value?.resetFields()
  changePasswordVisible.value = false
}

// 更新基本信息
const updateProfile = async () => {
  try {
    const valid = await editFormRef.value.validate()
    if (!valid) return

    updateLoading.value = true
    
    const response = await authApi.updateProfile({
      email: editForm.email,
      avatarUrl: userForm.avatarUrl
    })
    
    if (response.code === 200) {
      userForm.email = editForm.email
      auth.setUser(userForm)
      ElMessage.success(response.message || '基本信息更新成功')
      editProfileVisible.value = false
    } else {
      ElMessage.error(response.message || '更新失败')
    }
  } catch (error) {
    ElMessage.error(error.message || '更新失败，请稍后重试')
  } finally {
    updateLoading.value = false
  }
}

// 修改密码
const changePassword = async () => {
  try {
    const valid = await passwordFormRef.value.validate()
    if (!valid) return

    passwordLoading.value = true
    
    const response = await authApi.changePassword({
      currentPassword: passwordForm.currentPassword,
      newPassword: passwordForm.newPassword,
      confirmPassword: passwordForm.confirmPassword
    })
    
    if (response.code === 200) {
      ElMessage.success(response.message || '密码修改成功')
      changePasswordVisible.value = false
    } else {
      ElMessage.error(response.message || '密码修改失败')
    }
  } catch (error) {
    ElMessage.error(error.message || '密码修改失败，请稍后重试')
  } finally {
    passwordLoading.value = false
  }
}

// 头像相关
const changeAvatar = () => {
  previewAvatar.value = userForm.avatarUrl
  avatarDialogVisible.value = true
}

const beforeAvatarUpload = (file) => {
  console.log('文件上传前验证:', file)
  
  // 使用动态配置或默认配置
  const config = uploadConfig.value || {
    allowedTypes: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'],
    maxFileSize: 5 * 1024 * 1024 // 5MB
  }
  
  console.log('上传配置:', config)
  console.log('文件类型:', file.type)
  console.log('文件大小:', file.size)
  
  const isAllowedType = config.allowedTypes.includes(file.type)
  const isLtMaxSize = file.size <= config.maxFileSize

  if (!isAllowedType) {
    console.error('文件类型不支持:', file.type)
    ElMessage.error('头像图片只能是 JPG、PNG、GIF、WEBP 格式!')
    return false
  }
  if (!isLtMaxSize) {
    const maxSizeMB = Math.round(config.maxFileSize / 1024 / 1024)
    console.error('文件太大:', file.size, '最大允许:', config.maxFileSize)
    ElMessage.error(`头像图片大小不能超过 ${maxSizeMB}MB!`)
    return false
  }
  
  console.log('文件验证通过')
  return true
}

const handleAvatarChange = (file, fileList) => {
  console.log('文件选择改变:', file, fileList)
  
  if (file.raw) {
    selectedFile.value = file.raw  // 保存原始文件引用
    
    const reader = new FileReader()
    reader.onload = (e) => {
      previewAvatar.value = e.target.result
      console.log('文件预览生成成功')
    }
    reader.readAsDataURL(file.raw)
  }
}

const cancelAvatar = () => {
  previewAvatar.value = ''
  selectedFile.value = null
  avatarDialogVisible.value = false
}

const saveAvatar = async () => {
  try {
    avatarLoading.value = true
    
    console.log('开始保存头像')
    console.log('selectedFile.value:', selectedFile.value)
    console.log('previewAvatar.value:', previewAvatar.value)
    
    // 检查是否有选择的文件
    if (!selectedFile.value) {
      console.error('没有选择文件')
      ElMessage.error('请选择要上传的头像')
      return
    }
    
    // 如果没有预览图片，提示错误
    if (!previewAvatar.value) {
      console.error('没有预览图片')
      ElMessage.error('请先选择头像图片')
      return
    }
    
    console.log('准备上传文件:', {
      name: selectedFile.value.name,
      size: selectedFile.value.size,
      type: selectedFile.value.type
    })
    
    // 创建FormData对象
    const formData = new FormData()
    formData.append('file', selectedFile.value)
    
    console.log('FormData创建完成，开始上传')
    
    // 上传头像
    const response = await avatarApi.uploadAvatar(formData)
    console.log('上传响应:', response)
    
    if (response.code === 200) {
      // 更新本地用户信息
      userForm.avatarUrl = response.data
      
      // 立即更新localStorage中的用户信息
      const updatedUser = { ...userForm }
      auth.setUser(updatedUser)
      
      ElMessage.success('头像更新成功')
      avatarDialogVisible.value = false
      
      // 清理文件引用
      selectedFile.value = null
      previewAvatar.value = ''
      
      // 重新加载用户信息以确保数据一致性
      await loadUserInfo()
      
      console.log('Profile: 头像更新完成，用户信息已同步', updatedUser)
    } else {
      console.error('上传失败:', response)
      ElMessage.error(response.message || '头像上传失败')
    }
    
  } catch (error) {
    console.error('头像上传异常:', error)
    ElMessage.error('头像上传失败，请稍后重试')
  } finally {
    avatarLoading.value = false
  }
}

// 删除头像
const deleteAvatar = async () => {
  try {
    const response = await avatarApi.deleteAvatar()
    if (response.code === 200) {
      // 更新本地用户信息
      userForm.avatarUrl = '/images/avatars/default-user.png'
      
      // 立即更新localStorage中的用户信息
      const updatedUser = { ...userForm }
      auth.setUser(updatedUser)
      
      ElMessage.success('头像删除成功')
      
      // 重新加载用户信息以确保数据一致性
      await loadUserInfo()
      
      console.log('Profile: 头像删除完成，用户信息已同步', updatedUser)
    } else {
      ElMessage.error(response.message || '头像删除失败')
    }
  } catch (error) {
    console.error('头像删除失败:', error)
    ElMessage.error('头像删除失败，请稍后重试')
  }
}
</script>

<style scoped>
.profile-container {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  padding: 0;
  width: 100%;
}

/* 顶部横幅 */
.profile-hero {
  position: relative;
  height: 280px;
  overflow: hidden;
  margin-bottom: 40px;
}

.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  opacity: 0.9;
}

.hero-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 40px;
  gap: 32px;
}

.user-avatar-section {
  flex-shrink: 0;
}

.avatar-wrapper {
  position: relative;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.avatar-wrapper:hover {
  transform: scale(1.05);
}

.user-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.2);
  object-fit: cover;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.avatar-edit-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  color: white;
  font-size: 24px;
}

.avatar-wrapper:hover .avatar-edit-overlay {
  opacity: 1;
}

.user-info {
  color: white;
}

.username {
  font-size: 36px;
  font-weight: 700;
  margin: 0 0 8px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-role {
  font-size: 18px;
  margin: 0 0 16px 0;
  opacity: 0.9;
}

.user-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  opacity: 0.9;
}

/* 统计卡片区域 */
.stats-section {
  padding: 0 40px;
  margin-bottom: 40px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
}

.stat-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}



.stat-icon.account-status {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-icon.join-date {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-content {
  flex: 1;
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: #64748b;
}

/* 卡片区域 */
.cards-section {
  padding: 0 40px 40px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
}

.info-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition: all 0.3s ease;
}

.info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.info-card.full-width {
  grid-column: 1 / -1;
}

.card-header {
  padding: 24px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.card-content {
  padding: 0 24px 24px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid #f1f5f9;
}

.info-item:last-child {
  border-bottom: none;
}

.info-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 14px;
}

.info-value {
  color: #1e293b;
  font-weight: 500;
}

/* 活动记录 */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 16px;
}

.activity-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-weight: 500;
  color: #1e293b;
  margin-bottom: 4px;
}

.activity-time {
  font-size: 14px;
  color: #64748b;
}

/* 头像上传 */
.avatar-upload {
  text-align: center;
}

.avatar-uploader {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-uploader:hover {
  border-color: #667eea;
  background: #f8fafc;
}

.avatar-uploader-placeholder {
  text-align: center;
}

.avatar-uploader-icon {
  font-size: 32px;
  color: #9ca3af;
  margin-bottom: 8px;
}

.upload-text {
  font-size: 14px;
  color: #6b7280;
}

.avatar-preview {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
}

.upload-tips {
  color: #6b7280;
  font-size: 14px;
  line-height: 1.6;
}

.upload-tips p {
  margin: 4px 0;
}

/* 头像弹窗底部样式 */
.avatar-dialog-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.footer-left {
  flex: 1;
}

.footer-right {
  display: flex;
  gap: 12px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .profile-container {
    padding: 0;
  }
  
  .hero-content {
    padding: 0 20px;
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }
  
  .username {
    font-size: 28px;
  }
  
  .user-meta {
    justify-content: center;
  }
  
  .stats-section, .cards-section {
    padding: 0 20px 40px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .cards-grid {
    grid-template-columns: 1fr;
  }
}
</style> 